package com.warrantyhotel.android.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.warrantyhotel.android.R;
import com.warrantyhotel.android.model.PurchaseObject;

public class BuyCreditsAdapter extends ArrayAdapter<PurchaseObject> {

	private Context context;
	private ArrayList<PurchaseObject> list;

	public BuyCreditsAdapter(Context context, int textViewResourceId, ArrayList<PurchaseObject> list) {
		super(context, textViewResourceId, list);
		this.list = list;
		this.context = context;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if (v == null) {
			LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.buy_credit_item, null);
		}
		TextView title = (TextView) v.findViewById(R.id.buy_credit_title);
		TextView value = (TextView) v.findViewById(R.id.buy_credit_value);

		title.setText(list.get(position).getTitle());
		value.setText(list.get(position).getDescription());

		return v;
	}

}
